home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / qtools0.2-src.lha / src / libqdisplay / cache.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-10  |  2.5 KB  |  82 lines

  1. #ifndef    CACHE_H
  2. #define    CACHE_H
  3.  
  4.    /*
  5.     * I think this is the best point to implement an _effective_ cache
  6.     * the brute force method fills in an array of "struct cachedface *faceCache[numfaces][MIPMAP_MAX]"
  7.     * next step: the definition of an cacheface holds the different mip-sizes
  8.     */
  9.  
  10. struct bitmap {
  11.   short int width, height;                    /* */
  12.   int size;                            /* */
  13.   unsigned char *data;                        /* always 8bit indexed datas */
  14. };
  15.  
  16. struct bitdim {
  17.   short int width, height;                    /* */
  18.   int size;                            /* */
  19. };
  20.  
  21. struct faceextent {
  22.   int u0, u1;                            /* u0 is also the u for texture-gradients (except water/sky/..) */
  23.   int v0, v1;                            /* v0 is also the v for texture-gradients (except water/sky/..) */
  24.   int u10, v10;                            /* */
  25. };
  26.  
  27. struct textgradient {
  28.   float u, v;                            /* same as u0/v0 or 0 subtracted by vec[j][3] */
  29.   vec3_t uv0, uv1;                        /* */
  30.   vec3_t scaled;                        /* */
  31.   struct dplane_t *plane;                    /* textures plane */
  32. };
  33.  
  34. struct fastmipmap {
  35.   struct bitmap rawBody;                    /* */
  36.   struct bitdim newBody;                    /* */
  37.   int step, shift, row;                        /* */
  38.   int y, x0;                            /* */
  39.   double rescale;                        /* (8 >> mip) / 8.0 */
  40. };
  41.  
  42. struct texture {
  43.   bool texChanged;                        /* interface to dynamic changing and updating */
  44.   short int lastMip;                        /*  */
  45.  
  46.   short int textureType;                    /* the type of texture (constant) */
  47.   unsigned char textureColor;                    /* flat-color of the texture */
  48.   struct fastmipmap mipMaps[MIPMAP_MAX];            /* four sizes and four pointer to the textures (allmost constant, except for animating textures) */
  49.  
  50.   short int *lightSString[MAXLIGHTMAPS];            /* the type of lighting (points directly into the lightstringtable) */
  51.   short int lightSLength[MAXLIGHTMAPS];                /* the type of lighting (points directly into the lightlengthtable) */
  52.   struct bitmap lightmap;                    /* the buffer for holding the lightmap (constant size) */
  53.   unsigned char *lightdata;                    /* the raw lightmap (always 8bit alpha) */
  54.  
  55.   struct faceextent faceExtent;
  56.   struct textgradient textGradient;
  57.  
  58.   void *tiled;                            /* the buffer for holding the temporary datas in 8, 16 or 24 bit */
  59. };
  60.  
  61.    /*
  62.     */
  63.  
  64. extern struct texture **cachedFaces;
  65.  
  66. void InitFaceCache(__memBase);
  67. struct texture *CacheFace(__memBase, int face);
  68. void UnCacheFace(__memBase, int face);
  69.  
  70. static inline struct texture *GetCache(__memBase, int face);
  71. static inline struct texture *GetCache(__memBase, int face)
  72. {
  73.   struct texture *ret;
  74.  
  75.   if (!(ret = cachedFaces[face]))
  76.     ret = cachedFaces[face] = CacheFace(bspMem, face);
  77.  
  78.   return ret;
  79. }
  80.  
  81. #endif
  82.